<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            width: 500px;
            margin: 100px auto;
            border-collapse: collapse;
            text-align: center;
        }

        td,
        th {
            border: 1px solid #333;
        }

        thead tr {
            height: 40px;
            background-color: #ccc;
        }
    </style>
</head>

<body>
    <table>
        <thead>
            <tr>
                <th>姓名</th>
                <th>课程</th>
                <th>成绩</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <!-- <tr>
                <td>赵玉真</td>
                <td>Java</td>
                <td>40</td>
                <td><a href="">删除</a></td>
             </tr>
             <tr>
                <td>胡歌</td>
                <td>仙剑</td>
                <td>40</td>
                <td><a href="">删除</a></td>
             </tr> -->

        </tbody>
    </table>
    <script>
        var date = [
            {
                name: '赵玉真',
                kc: 'java',
                cj: 30
            },
            {
                name: '胡歌',
                kc: '仙剑',
                cj: 30
            },
            {
                name: '胡歌',
                kc: '仙剑',
                cj: 30
            },
        ]
        var tby = document.querySelector('tbody')
        for (let i = 0; i < date.length; i++) {
            var tr = document.createElement('tr')
            tby.appendChild(tr)

            for (const key in date[i]) {
                //    console.log(date[i][key]); 
                var td = document.createElement('td')
                tr.appendChild(td)
                td.innerHTML = date[i][key]
            }
            var td = document.createElement('td')
            tr.appendChild(td)
            td.innerHTML = '<a href="javascript:;">删除</a>'
        }
        var a = document.querySelectorAll('a')
        for (let i = 0; i < a.length; i++) {
            a[i].onclick = function () {
                console.log();
                 tby.removeChild(this.parentNode.parentNode)  
            }
        }


    </script>
</body>

</html>